<meta charset="UTF-8">

<input id="ipt1" type="text"><br>
<button id="btn1">按钮1</button><br>
<input id="ipt2" type="text"><br>
<button id="btn2">按钮2</button><br>

<script type="module">
    import sleep from "../utils/sleep.js";

	(async function(){
		await sleep(2000);
		console.log(1);
	})();

	(async function(){
		await sleep(1000);
		console.log(2);
	})();

	btn1.onclick = function(){
		for(var i=0; i<1000000; i++){
			ipt1.value = i;
		}
	};

	btn2.onclick = async function(){
		for(var i=0; i<1000000; i++){
			ipt2.value = i;
			await sleep(0);
		}
	};

</script>